package com.gn.test;

import com.sun.deploy.ref.AppModel;

import java.util.ArrayList;
import java.util.List;

/**
 * @version 1.0
 * @Author: 许啸林
 * @Date: 2022/1/20 14:54
 *
 *  自定义泛型结构  泛型类 泛型接口 泛型方法
 * */
public class Order<T> {
    private Integer orderId;
    private String orderName;
    // 类的内部结构可以使用类的泛型
    private T orderT;

    // 泛型方法,在方法中出现了泛型结构，泛型参数与类的泛型参数没有关系
    // 泛型方法可以存在非泛型类
    // 将数组转换为集合
    public static <E> List<E> arryToList(E[] arr) {
        List<E> list = new ArrayList<>();
        for(E i : arr) {
            list.add(i);
        }
        return list;
    }

    public Order() {
    }

    public Order(Integer orderId, String orderName, T orderT) {
        this.orderId = orderId;
        this.orderName = orderName;
        this.orderT = orderT;
    }

    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public String getOrderName() {
        return orderName;
    }

    public void setOrderName(String orderName) {
        this.orderName = orderName;
    }

    public T getOrderT() {
        return orderT;
    }

    public void setOrderT(T orderT) {
        this.orderT = orderT;
    }
}
